#define fexit(s) { fprintf( stderr, "%s\n", s ); exit(1); }
#include "jerasure.h"

int main( int argc, char** argv )
{
	JER_Matrix *matrix;
	int r = atoi( argv[1] );
	int c = atoi( argv[2] );
	int w = atoi( argv[3] );
	JER_Matrix *matrix2;
	int i, fsize;
	int r1, r2;

	matrix = new JER_Matrix( r, c, w );
	if( matrix == NULL )
		fexit( "Matrix could not be allocated." );
	srand48(c);
	fsize = 1 << w;
	for( i = 0; i < r * c; i++ )
		matrix->Set( i/c, i%c, lrand48() % fsize );
	matrix->Print();

	for( i = 0; i < w; i++ )
	{
		r1 = lrand48() % r;
		r2 = lrand48() % r;
		fprintf( stdout, "r1 = %d\nr2 = %d\n", r1, r2 );
		matrix->Row_PlusEquals( r1, r2 );
		matrix->Print();
		fprintf( stdout, "----------\n" );
	}

	return 0;
}
